package com.clickpaas.timelineofUN.bean;

import com.bizcloud.ipaas.t7aef1c33e4a445f2833f9d631cb90c38.d20210202091529.model.*;
import org.springframework.stereotype.Component;

@Component
public class TimelineDTOBean {

    /**
     * 项目对象
     * @return ProjectDTO
     */
    public ProjectDTO projectDTO(){
        try {
            return getDTO(ProjectDTO.class);
        }catch (Exception e){
            return new ProjectDTO();
        }
    }

    /**
     * 项目对象分页
     * @return ProjectDTOPageInfo
     */
    public ProjectDTOPageInfo projectDTOPageInfo() {
        try {
            return getDTO(ProjectDTOPageInfo.class);
        }catch (Exception e){
            return new ProjectDTOPageInfo();
        }
    }

    /**
     * 动态更新对象
     * @return UpdateDynamicsDTO1
     */
    public UpdateDynamicsDTO updateDynamicsDTO() {
        try {
            return getDTO(UpdateDynamicsDTO.class);
        }catch (Exception e){
            return new UpdateDynamicsDTO();
        }
    }

    /**
     * 动态更新对象分页
     * @return UpdateDynamicsDTOPageInfo
     */
    public UpdateDynamicsDTOPageInfo updateDynamicsDTOPageInfo() {
        try {
            return getDTO(UpdateDynamicsDTOPageInfo.class);
        }catch (Exception e){
            return new UpdateDynamicsDTOPageInfo();
        }
    }

    /**
     * 注册用户对象
     * @return SystemUserDTO1
     */
    public SystemUserDTO systemUserDTO() {
        try {
            return getDTO(SystemUserDTO.class);
        }catch (Exception e){
            return new SystemUserDTO();
        }
    }

    /**
     * 注册用户对象分页
     * @return SystemUserDTOPageInfo
     */
    public SystemUserDTOPageInfo systemUserDTOPageInfo() {
        try {
            return getDTO(SystemUserDTOPageInfo.class);
        }catch (Exception e){
            return new SystemUserDTOPageInfo();
        }
    }

    /**
     * 项目方对象
     * @return ProjectProviderDTO1
     */
    public ProjectProviderDTO projectProviderDTO() {
        try {
            return getDTO(ProjectProviderDTO.class);
        }catch (Exception e){
            return new ProjectProviderDTO();
        }
    }

    /**
     * 项目方对象分页
     * @return ProjectProviderDTOPageInfo
     */
    public ProjectProviderDTOPageInfo projectProviderDTOPageInfo() {
        try {
            return getDTO(ProjectProviderDTOPageInfo.class);
        }catch (Exception e){
            return new ProjectProviderDTOPageInfo();
        }
    }

    /**
     * 获取沙箱ID
     * @param clazz
     * @param <T>
     * @return
     * @throws Exception
     */
    private  <T> T getDTO(Class<T> clazz) throws Exception {
        T t = (T) clazz.newInstance();
        //TODO下个版本更新沙箱ID
        /*Method setatsandboxDBId = null;
        try {
            setatsandboxDBId = t.getClass().getDeclaredMethod(ConstantFile._SET_AT_SANDBOXDB_ID, String.class);
            if (StringUtils.isNotBlank(AutoLoadConfig.SANDBOX_ID)){
                setatsandboxDBId.invoke(t,AutoLoadConfig.SANDBOX_ID);
            }
        }catch (Exception e){
            log.info("对象【{}】获取沙箱ID失败！",t);
            return (T) t;
        }*/
        return (T) t;
    }
}
